package com.zhaoxi.project.wms.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.wms.domain.MesTaskBom;
import com.zhaoxi.project.wms.service.impl.MesTaskBomServiceImpl;
import com.zhaoxi.framework.web.BaseService;
import com.zhaoxi.framework.web.PageData;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 生产任务产品用料Controller
 *
 * @author zhaoxi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/mes/taskBom")
public class MesTaskBomController extends BaseService
{
    @Autowired
    private MesTaskBomServiceImpl mesTaskBomService;

    /**
     * 查询生产任务产品用料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:taskBom:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesTaskBom mesTaskBom)
    {
        startPage();
        List<MesTaskBom> list = mesTaskBomService.selectMesTaskBomList(mesTaskBom);
        return getDataTable(list);
    }

    /**
     * 导出生产任务产品用料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:taskBom:export')")
    @Log(title = "生产任务产品用料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesTaskBom mesTaskBom)
    {
        List<MesTaskBom> list = mesTaskBomService.selectMesTaskBomList(mesTaskBom);
        ExcelUtil<MesTaskBom> util = new ExcelUtil<MesTaskBom>(MesTaskBom.class);
        util.exportExcel(response, list, "生产任务产品用料数据");
    }

    /**
     * 获取生产任务产品用料详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:taskBom:query')")
    @GetMapping(value = "/{taskId}")
    public PageData getInfo(@PathVariable("taskId") Long taskId)
    {
        return success(mesTaskBomService.selectMesTaskBomByTaskId(taskId));
    }

    /**
     * 新增生产任务产品用料
     */
    @PreAuthorize("@ss.hasPermi('wms:taskBom:add')")
    @Log(title = "生产任务产品用料", businessType = BusinessType.INSERT)
    @PostMapping
    public PageData add(@RequestBody MesTaskBom mesTaskBom)
    {
        return toAjax(mesTaskBomService.insertMesTaskBom(mesTaskBom));
    }

    /**
     * 修改生产任务产品用料
     */
    @PreAuthorize("@ss.hasPermi('wms:taskBom:edit')")
    @Log(title = "生产任务产品用料", businessType = BusinessType.UPDATE)
    @PutMapping
    public PageData edit(@RequestBody MesTaskBom mesTaskBom)
    {
        return toAjax(mesTaskBomService.updateMesTaskBom(mesTaskBom));
    }

    /**
     * 删除生产任务产品用料
     */
    @PreAuthorize("@ss.hasPermi('wms:taskBom:remove')")
    @Log(title = "生产任务产品用料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskIds}")
    public PageData remove(@PathVariable Long[] taskIds)
    {
        return toAjax(mesTaskBomService.deleteMesTaskBomByTaskIds(taskIds));
    }
}
